<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h2>进入页面获取 内容--后台</h2>

    <script>
        //1创建xhr对象
        var xhr = new XMLHttpRequest();
        //2准备发起
        //语法xhr.open('请求方法post get','url地址','boolean')默认true异步请求
        xhr.open('get', '02ajax.php', true);
        //3.发送send() get请求send()内容空
        xhr.send();
        //4.监听函数
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if (xhr.status == 200) {
                    console.log(xhr.responseText); //返回字符串格式
                }
            }
        }
    </script>
</body>

</html>